package dao;

import entity.User;
import org.apache.ibatis.annotations.*;

/**
 * @author 石小俊
 * @date 2023年11月07日 10:39
 */
public interface UserMapper {

    @Insert(value = "insert into t_user(username,password,phone,address) values(#{username},#{password},#{phone},#{address})")
    void insertUser(User user);

    @Delete("delete from t_user where id = #{id}")
    void deleteById(Integer id);

    @Update("update t_user set username = #{username},password=#{password},phone=#{phone},address=#{address} where id = #{id}")
    void updateUser(User user);

    @Select("select * from t_user where id = #{id}")
    User selectById(Integer id);

    @Select("select * from t_user2 where user_id = #{id}")
    @Results(value = {
            @Result(id = true,property = "id",column = "user_id"),
            @Result(property = "username",column = "user_username"),
            @Result(property = "password",column = "user_password"),
            @Result(property = "phone",column = "user_phone"),
            @Result(property = "address",column = "user_address")
    })
    User selectById2(Integer id);
}
